package com.jackie.setting

import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * 基础的[RecyclerView.Adapter]类，封装了子项点击的监听
 */
abstract class BaseAdapter<T, VH: RecyclerView.ViewHolder>(open var data: List<T>): RecyclerView.Adapter<VH>() {

    var onItemClickListener: ((View, T, Int) -> Unit)? = null

    override fun onBindViewHolder(holder: VH, position: Int) {
        holder.itemView.setOnClickListener {
            onItemClickListener?.invoke(it, data[position], position)
        }
    }
}